/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package network;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import weibo4j.Timeline;
import weibo4j.Weibo;
import weibo4j.model.Paging;
import weibo4j.model.Status;
import weibo4j.model.WeiboException;

/**
 *
 * @author Administrator
 */
public class statusScore {

    public static void main(String args[]) throws FileNotFoundException, IOException, WeiboException, InterruptedException, ClassNotFoundException, InstantiationException, IllegalAccessException, SQLException {
        String access = Auth.Auth4Code.getCode();
        Weibo weibo = new Weibo();
        weibo.setToken(access);
        DataPreparation data = new DataPreparation();
        statusScore(data);
    }

    public static void statusScore(DataPreparation data) throws FileNotFoundException, IOException, WeiboException, InterruptedException {
        relationScore.relationScore(data);
        Timeline tm = new Timeline();
        double alpha = 1E-6;
        List<Status> sm = tm.getFriendsTimeline(0, 0, new Paging(1, 200));
        sm.addAll(tm.getFriendsTimeline(0, 0, new Paging(2, 200)));
        Date today = Calendar.getInstance().getTime();
        List<String> statusList = new ArrayList<String>();
        List<String> status = new ArrayList<String>();
        for (Status s : sm) {
            double statusScore;
            double I=0;
            String un = s.getUser().getName();
            String uid = s.getUser().getId();
            int commentCount = s.getCommentsCount();
            int repostCount = s.getRepostsCount();
            if (data.influence.containsKey(uid)) {
                I = data.influence.get(uid);
            }
            int N = commentCount + repostCount;
            Date subTime = s.getCreatedAt();
            double deltaT = (subTime.getTime() - today.getTime());
            double fT = Math.exp(alpha * deltaT);
            //double statusScore=I*N*fT;
            statusScore = I;
            statusList.add(statusScore + "//==//" + un + "//==//" + s.getText());
        }
        Collections.sort(statusList);
        int count = statusList.size();
        for (int i = 0; i < count; i++) {
            String strings[] = statusList.get(i).split("//==//");
            String score = strings[0];
            String username = strings[1];
            String text = strings[2];
            String uid = data.data.username2id.get(username);
            //if (!data.data.mediaIDs.contains(uid))
            {
                
                System.out.println(username + " " + text);
            }
        }
    }
}
